<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>提现</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" href="__PUBLIC__/static/wx/css/iconfont.css" />
		<link rel="stylesheet" href="__PUBLIC__/static/wx/css/new.css?1=1" />
		<link rel="stylesheet" href="__PUBLIC__/static/wx/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/css/wallet.css" />
		<script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
	</head>
	<style>
		element.style .mui-content {
			background-color: white;
		}
		
		.tix_num input {
			font-size: 1.2rem;
			width: 80%;
			font-weight: lighter;
			margin-top: 0.2rem;
			border: 0;
		}
		
		.tix_num img {
			width: 10%; 
		}
		
		.tx {
			font-size: 1.5rem;
			margin-bottom: 10px;
		}
		.mui-title{
			margin-left: 18px; 
		}
		.mui-bar-nav,.gerzl_btn a{
    	    background-color: #01aaed;
	    } 
	</style>

	<body style="background: white;">
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">提现</h1>
		</header>
		<div style="padding: 54px 0 0;">
			<div class="tix_numbox">
				<div class="tx">提现额度</div>
				<div class="tix_num">
					<label><img src="__PUBLIC__/static/wx/images/glj_money.png"></label>
					<input type="text" placeholder="输入提现金额" onkeyup="key_up(this)" id="tixian_money" />
				</div>
				<div class="tips">当前钱包余额：<span id="yue">{$info_user['balance']}</span></div>
			</div>
			<div class="tix_numbox">
				<div class="tx">实际到账</div>
				<div class="tix_num">
					<label><img src="__PUBLIC__/static/wx/images/glj_money.png"></label>
					<input type="number" placeholder="0" id="tmuch" />
				</div> 
			</div> 
			<div class="btnbox2"><button type="button" class="dzyhq_btn tixian_btn" onclick="submit_tx()">提现</button></div>
		</div>
        <div class="tuig_tips3">申请提现成功后，该笔提现T+1到账银行卡。</div>
	</body>

</html>
{include file="public/footer" /}
<script>
	var member_verif = "{$info_user['is_verify']}";
	var balance = "{$balance}";
	if(member_verif!=1){
		layer.msg('请先实名认证！', {
				 time: 1500 
		}, function(){
			location.href="renzhen.html";
		});
	}
	
	function key_up(obj) {
		obj.value = obj.value.replace(/[^\d]/g, ""); //清除“数字”和“.”以外的字符
		obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
		obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
		obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", "."); 
		$("#tmuch").val(parseFloat(obj.value));
	}
	
	function submit_tx(){
		$('.tixian_btn').attr("disabled",true);
	   	var obj = $('input:radio[name="type"]:checked').val();
		var tixian_money =$("#tixian_money").val();
		var yue=$("#yue").text();
		if(tixian_money ==""){
			layer.msg("请输入提现金额");
			$('.tixian_btn').attr("disabled",false);
			return false;
		}
		if(parseInt(tixian_money) > parseInt(yue)){
			layer.msg("余额不足");
			$('.tixian_btn').attr("disabled",false);
			return false;
		}
		
		if(parseFloat(tixian_money)<10){
			layer.msg("提现金额不能小于10元");
			$('.tixian_btn').attr("disabled",false);
			return false;
		}
		
		if(parseFloat(tixian_money)>2000){
			layer.msg("单次提现金额不能超过2000元");
			$('.tixian_btn').attr("disabled",false);
			return false;
		}
		if(balance.slice(1) >= 5000){
			layer.msg("一天最高提现额度为5000元");
			$('.tixian_btn').attr("disabled",false);
			return false;
		}
		
		if(parseFloat(tixian_money) % 10 != 0){
			layer.msg("提现金额必须是10的整数倍");
			$('.tixian_btn').attr("disabled",false);
			return false;
		}
		
		if(parseFloat(tixian_money)>20000&&obj==2){
			layer.msg("T+1方式提现金额最多可提现20000元");
			$('.tixian_btn').attr("disabled",false);
			return false;
		}
		
//		if(parseFloat(tixian_money)>1000&&obj==1){
//			layer.msg("T+0方式提现金额不能大于1000元");
//			$('.tixian_btn').attr("disabled",false);
//			return false;
//		}
		$.ajax({
				type:"post",
				url: "{:url('index/member/tixian')}",
				data: {
					balance		: $('#tixian_money').val()
				},
				success: function(data) {  
					if(data.code == 200) {
						layer.msg('申请提现成功！', {
						  time: 1500 
						}, function(){
							location.href="index.html";
						});
						
					}else{
						layer.msg(data.msg);
						$('.tixian_btn').attr("disabled",false);
						console.log(data.msg);
					}
				}
			})
		}
</script>

